package net.cyndeline.events

import net.cyndeline.entitySystem.Event


/**
 * Keeps track of if an event has had its values set, and lets it throw an
 * error if it is modified. Used to keep some events immutable despite
 * using var's.
 */
trait ModifyError {
  private var modified = Set[String]()
  
  def modify(key: String, event: AnyRef) {
    if (modified contains key) {
      throw new Error("Attempted to set value " + key + " twice in " + event.getClass)
    } else {
      modified += key
    }
  }
}